package com.team.six.bluecatshop.service;

import com.team.six.bluecatshop.domain.Admin;
import com.team.six.bluecatshop.mapper.AdminMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminMapper adminMapper;

    @Override
    @Transactional
    public void add(Admin admin) {
        adminMapper.insert(admin);
    }

    @Override
    @Transactional
    public void remove(String id) {
        adminMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Admin findById(String id) {
        Admin admin=adminMapper.selectByPrimaryKey(id);
        return admin;
    }

    @Override
    public List<Admin> findAll() {
        List<Admin> adminList = adminMapper.findAll();
        return adminList;
    }

    @Override
    public Admin findAdminByName(String name) {
        Admin admin = adminMapper.findByName(name);
        return admin;
    }

    @Override
    @Transactional
    public void updateByPrimaryKey(Admin admin) {
        adminMapper.updateByPrimaryKeySelective(admin);
    }
}
